﻿using System;
using System.Collections.Generic;
using Color = System.Drawing.Color;
using SwinGame;
using System.Diagnostics;

namespace RandomShapeGenerator.src
{
    public class Drawing
    {
        private List<Shape> ShapeList;

        private Shape selectedShape;

        private Shape pallette;

        public Shape Pallette
        {
            get { return pallette; }
            set { pallette = value; }
        }

        public Shape SelectedShape
        {
            get { return selectedShape; }
            set { selectedShape = value; }
        }

        public Drawing()
        {
            ShapeList = new List<Shape>();
        }


        public void AddShape(Shape toAdd)
        {
            ShapeList.Add(toAdd);
        }

        public void RemoveShape(Shape toRemove)
        {
            ShapeList.Remove(toRemove);
            selectedShape = null;
        }
        public void SelectShapeAtPoint(float MousePosX, float MousePosY)
        {
            selectedShape = null;
            foreach (Shape s in ShapeList)
            {
                if (s.IsAt(MousePosX, MousePosY))
                {
                    selectedShape = s;
                    //returns; <in swinbrain the code says to do return.. but i'm not sure why.
                }
            }

        }

        //drawing (controlling)
        public void Draw()
        {
            foreach (Shape s in ShapeList) 
            {
                s.Draw();
                if(selectedShape !=null)
                selectedShape.Highlight();
            }

        }

    }
}
